<?php
/**
 * Description of Router
 *
 * @author henson
 */

class Router
{
    private $module = 'event'; // default module
	
    private $action = 'index';  // default action

    public function __construct()
    {
	    $route = @$_GET['r'];
	    preg_match('#^(\w+)(/(\w+))?$#isU', $route, $matches);
	    if(isset($matches[1]) && $matches[1])
	    {
		    $this->module = strtolower($matches[1]);
	    }
	    if(isset($matches[3]) && $matches[3])
	    {
		    $this->action = strtolower($matches[3]);
	    }
    }
    
    public function getRouter()
    {
	    $routeObj = new StdClass;
	    $routeObj->module = $this->module;
	    $routeObj->action = $this->action;
	    return $routeObj;
    }
}
